package com.eternal.base;

import android.os.StrictMode;

import com.eternal.base.config.ModuleLifecycleConfig;
import com.eternal.base.global.ActivityEvent;
import com.eternal.framework.bus.RxBus;
import com.eternal.framework.component.BaseApplication;


/**
 * @author li
 */
public class Application extends BaseApplication {
    @Override
    public void onCreate() {
        super.onCreate();

        setApplication(this, new AppStateChangeListener() {
            @Override
            public void appTurnIntoForeground() {
                RxBus.getDefault().post(new ActivityEvent(ActivityEvent.STATE_FOREGROUND));
            }

            @Override
            public void appTurnIntoBackGround() {
                RxBus.getDefault().post(new ActivityEvent(ActivityEvent.STATE_BACKGROUND));
            }
        });
        ModuleLifecycleConfig.initAhead(this);
        ModuleLifecycleConfig.initLow(this);
//        if (BuildConfig.DEBUG){ // ANR 检测
//            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
//                    .detectCustomSlowCalls() //API等级11，使用StrictMode.noteSlowCode
//                    .detectDiskReads()
//                    .detectDiskWrites()
//                    .detectNetwork()   // or .detectAll() for all detectable problems
//                    .penaltyDialog() //弹出违规提示对话框
//                    .penaltyLog() //在Logcat 中打印违规异常信息
//                    .penaltyFlashScreen() //API等级11
//                    .build());
//            StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
//                    .detectLeakedSqlLiteObjects()
//                    .detectLeakedClosableObjects() //API等级11
//                    .penaltyLog()
//                    .penaltyDeath()
//                    .build());
//        }
    }
}
